package edu.cs.usask.ca.silver.api.businesslogic;

import edu.cs.usask.ca.silver.api.persistence.StorageI;
import edu.cs.usask.ca.silver.businesslogic.ids.FileID;
import edu.cs.usask.ca.silver.businesslogic.ids.ModelProjectID;
import edu.cs.usask.ca.silver.businesslogic.ids.ModelVersionID;
import edu.cs.usask.ca.silver.businesslogic.ids.ScenarioCollectionID;
import edu.cs.usask.ca.silver.businesslogic.ids.ScenarioID;

/**
 * 
 * This interface specifies the major functionality that both local and remote
 * java bean implementations must satisfy.
 * 
 * @author Yudi Xue, Daniel Funk
 */
public interface AssociatedFileI {

	/**
	 * Takes a file from the local file system and puts it into storage -
	 * including file name, description and contents.
	 * 
	 * @param fName
	 *            The name to give the file
	 * @param fDescr
	 *            File description
	 * @param fileSourceLocation
	 *            The location of the file on local storage
	 * @param storage TODO
	 * @return The unique file id in silver for the added file
	 * @throws Exception
	 */
	public FileID createFile(String fName, String fDescr,
			String fileSourceLocation, StorageI storage) throws Exception;

	/**
	 * Returns the name of a file as string
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param storage TODO
	 * @return The file name
	 * @throws Exception
	 */
	public String getName(FileID fId, StorageI storage) throws Exception;

	/**
	 * Returns the description of a file as string
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param storage TODO
	 * @return The file description
	 * @throws Exception
	 */
	public String getDescription(FileID fId, StorageI storage) throws Exception;

	/**
	 * Takes a specified file from the storage layer and saves it to a specified
	 * location on the local disk.
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param destination
	 *            The target location where the file is to be (re-)created
	 * @param storage TODO
	 * @throws Exception
	 */
	public void getFileToLocalStorage(FileID fId, String destination, StorageI storage)
			throws Exception;

	/**
	 * Change/Set the name of a file in the storage layer
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param description
	 *            The (new) file name
	 * @param storage TODO
	 * @return TODO
	 * @throws Exception
	 */
	public boolean setDescription(FileID fId, String description, StorageI storage) throws Exception;

	/**
	 * Specify that a file is an input file for a given scenario
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param sId
	 *            A unique scenario identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToScenarioAsInputFile(FileID fId, ScenarioID sId, StorageI storage)
			throws Exception;

	/**
	 * Specify that a file is a trajectory file for a given scenario
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param sId
	 *            A unique scenario identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToScenarioAsTrajectoryFile(FileID fId, ScenarioID sId, StorageI storage)
			throws Exception;

	/**
	 * Specify that a file is an analysis file for a given scenario
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param sId
	 *            A unique scenario identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToScenarioAsAnalysisFile(FileID fId, ScenarioID sId, StorageI storage)
			throws Exception;

	/**
	 * Specify that a file is to be associated with a model project
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param mpId
	 *            A unique model project identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToModelProject(FileID fId, ModelProjectID mpId, StorageI storage)
			throws Exception;

	/**
	 * Specify that a file is to be associated with a model version
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param mvId
	 *            A unique model version identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToModelVersion(FileID fId, ModelVersionID mvId, StorageI storage)
			throws Exception;

	/**
	 * Specify that a file is to be associated with a scenario collection
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param scId
	 *            A unique scenario collection identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToScenarioCollection(FileID fId,
			ScenarioCollectionID scId, StorageI storage) throws Exception;

	/**
	 * Specify that a file is to be associated with a scenario
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param sId
	 *            A unique scenario identifier
	 * @param storage TODO
	 * @throws Exception
	 */
	public void addFileToScenario(FileID fId, ScenarioID sId, StorageI storage) throws Exception;

	/**
	 * Removes a file from the storage layer
	 * 
	 * @param fId
	 *            A unique file identifier
	 * @param storage TODO
	 * @return TODO
	 * @throws Exception
	 */
	public boolean deleteFile(FileID fId, StorageI storage) throws Exception;

	/**
	 * Backup db to a read-only db in .zip file
	 * 
	 * @param destination
	 *            -the file name ends with .zip
	 * @param storage TODO
	 * 
	 * @return - true if the backup was successful, false if the backup was
	 *         failed.
	 * 
	 * @throws Exception
	 */
	public boolean backupDB(String destination, StorageI storage) throws Exception;
}
